package com.example.mystore.controller;

import com.example.mystore.model.Product;
import com.example.mystore.model.ProductCategory;
import com.example.mystore.service.impl.UserProductCategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class UserProductCategoryController {

    @Autowired
    private UserProductCategoryService userProductCategoryService;

    @GetMapping("/api/category")
    public List<ProductCategory> getCategories() {
        return userProductCategoryService.getSpecificCategories();
    }


    @GetMapping("/api/categories")
    public List<ProductCategory> getAllCategories() {
        return userProductCategoryService.getAllCategories();
    }
    @GetMapping("/api/products/{typeId}")
    public List<Product> getProductsByTypeId(@PathVariable int typeId) {
        return userProductCategoryService.getProductsByTypeId(typeId);
    }
}
